1. Field of the Invention
The invention relates to an apparatus and method for audio encoding, more particularly to an apparatus and method for audio encoding without performing loop computations.
2. Description of the Related Art
For conventional audio encoding methods, reference can be made to U.S. Patent Application Publication No. 20040143431. Referring to FIG. 1, in the aforesaid patent application, a conventional audio encoding system 10, which is described in the Description of the Related Art therein, includes a Modified Discrete Cosine Transform (MDCT) module 12, a psychoacoustic model 14, a quantization module 16, an encoding module 18, and a packing module 19.
A Pulse Code Modulation (PCM) sample, which is also referred to as an audio frame, is inputted into the MDCT module 12 and the psychoacoustic model 14. The psychoacoustic model 14 analyzes the PCM sample to obtain a masking curve and a window message corresponding thereto. From a range defined by the masking curve, a range of audio signals perceivable by the human ear can be observed. The human ear can perceive only audio signals the intensities of which are larger than the masking curve.
The MDCT module 12 performs MDCT on the PCM sample according to the window message transmitted from the psychoacoustic model 14 so as to obtain a plurality of transformed MDCT samples. The MDCT samples are grouped into a plurality of frequency sub-bands having non-equivalent bandwidths according to the auditory characteristics of the human ear. Each frequency sub-band has a masking threshold.
The quantization module 16 and the encoding module 18 perform a bit allocation process on each frequency sub-band repeatedly to determine an optimum scale factor and a stepsize factor. Based on the scale factor and the stepsize factor, the encoding module 18 encodes each frequency sub-band using the Huffman coding. It is noted that the encoding based on the scale factor and the stepsize factor requires all the MDCT samples in each frequency sub-band to conform to the encoding distortion standard. That is, the final encoding distortion of each MDCT sample should be lower than the masking threshold determined by the psychoacoustic model 14 within a limited number of available bits.
After encoding by the encoding module 18, all the encoded frequency sub-bands are combined via the packing module 19 for packing with corresponding side information so as to obtain a final audio stream. The side information contains information related to the encoding procedure, such as window messages, stepsize factor information, etc.
Referring to FIG. 2, the bit allocation process performed by the quantization module 16 and the encoding module 18 includes the following steps:
Step 300: Start the bit allocation process.
Step 302: Quantize disproportionately all the frequency sub-bands according to a stepsize factor of the audio frame.
Step 304: Look up in a Huffman Table to calculate the number of bits required for encoding all the MDCT samples in each frequency sub-band under a distortionless state.
Step 306: Determine whether the required number of bits is lower than the number of available bits. If yes, go to step 310. If no, go to step 308.
Step 308: Increase the value of the stepsize factor, and repeat step 302.
Step 310: De-quantize the quantized frequency sub-bands.
Step 312: Calculate the distortion of each frequency sub-band.
Step 314: Store a scale factor of each frequency sub-band and the stepsize factor of the audio frame.
Step 316: Determine whether the distortion of any frequency sub-band is higher than the masking threshold. If no, go to step 322. If yes, go to step 317.
Step 317: Determine whether there are other termination conditions, e.g., the scale factor has reached an upper limit, that have been met. If no, go to step 318. If yes, go to step 320.
Step 318: Increase the value of the scale factor.
Step 319: Amplify all the MDCT samples in the frequency sub-band according to the scale factor, and go to step 302.
Step 320: Determine whether the scale factor and the stepsize factor are optimum values. If yes, go to step 322. If no, go to step 321.
Step 321: Adopt the previously recorded optimum value, and go to step 322.
Step 322: End the bit allocation process.
The above bit allocation process primarily includes two loops. One is from step 302 to step 308, and is generally referred to as a bit rate control loop, which is used for determining the stepsize factor. The other is from step 302 to step 322, and is generally referred to as a distortion control loop, which is used for determining the scale factor. To complete one bit allocation process, it generally requires the execution of many distortion control loops, and each distortion control loop requires execution of many bit rate control loops, thereby resulting in reduced efficiency.
FIG. 3 illustrates a method proposed in the aforesaid U.S. patent publication to improve efficiency of the bit allocation process. The proposed bit allocation process includes the following steps:
Step 400: Start the bit allocation process.
Step 402: Execute a scale factor prediction method so that each frequency sub-band generates a corresponding scale factor.
Step 404: Execute a stepsize factor prediction method to generate a predicted stepsize factor of an audio frame.
Step 406: Quantize each frequency sub-band according to the predicted stepsize factor.
Step 408: Encode each quantized frequency sub-band using an encoding scheme.
Step 410: Determine whether a predetermined bit value is used most efficiently according to a determination criterion. If yes, go to step 414. If no, go to step 412.
Step 412: Adjust the value of the predicted stepsize factor, and repeat step 406.
Step 414: End the bit allocation process.
Although the process proposed in the aforesaid patent publication can simplify the number of loops, it still contains one primary loop (i.e., from steps 406 to 412). Besides, steps 402 and 404 actually further include many sub-steps. Therefore, the process proposed in the aforesaid patent publication still cannot eliminate loop computations, and cannot achieve better efficiency in audio encoding. In addition, in realizing the hardware for the audio encoding system, effective control may not be achieved due to the presence of the loop.